package chapter_7;

import java.io.Serializable;
import java.util.Objects;

public class Dog implements Serializable , Comparable {

    private static final long serialVersionUID = 3L;

    private static String kind;
    private String name;
    private int age;
    private transient String color;
    public Dog(){
    }
    public Dog(String name, int age, String color) {
        this.name = name;
        this.age = age;
        this.color = color;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getColor() {
        return color;
    }
    public void setColor(String color) {
        this.color = color;
    }

    @Override
    public String toString() {
        return "Dog{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", color='" + color + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        Dog dog = (Dog) o;
        return age == dog.age && Objects.equals(name, dog.name) && Objects.equals(color, dog.color);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, color);
    }

    @Override
    public int compareTo(Object o) {
        Dog dog = (Dog) o;
        if(this.age > dog.age){
            return 1;
        }else if(this.age < dog.age){
            return -1;
        }
        return 0;
    }
}
